angular.module('app')

.factory('TaskService', ['$http', function($http) {
	return {
		findAllTasks: function() { 
			console.log("GET findAllTasks.es");
			return $http({
				method: 'GET',
				url: 'findAllTasks.es',
			})
		},
		
		saveOrUpdateTask: function(task) { 
			console.log("POST saveOrUpdateTask.es. task:" + task);
			return $http({
				method: 'POST',
				url: 'saveOrUpdateTask.es',
				headers: {'Content-type': 'application/json;charset=UTF-8'},
				data: task,
			})
		},
		
		deleteTask: function(task) { 
			console.log("POST deleteTask.es");
			return $http({
				method: 'POST',
				url: 'deleteTask.es',
				data: task,
			})
		},
		
		loadTaskDefs: function() { 
			console.log("GET loadTaskDefs.es");
			return $http({
				method: 'GET',
				url: 'loadTaskDefs.es',
			})
		},

	};
}])